home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / skipandgouls.swf / scripts / __Packages / maze / elements / Pipe.as next >
Encoding:
Text File  |  2007-10-01  |  2.4 KB  |  76 lines

  1. class maze.elements.Pipe extends sarbakan.visual.element.DynamicElement
  2. {
  3.    var mc;
  4.    var bLastPipe;
  5.    var oOwner;
  6.    function Pipe(l_oLayer, l_oPipeInfos)
  7.    {
  8.       super("pipe" + sarbakan.visual.element.BaseElement.getNextID());
  9.       var _loc5_ = l_oLayer.mc;
  10.       this.mc = _loc5_.attachMovie("pipe","pipe" + sarbakan.visual.element.BaseElement.nNextID,maze.MazeData.DEPTH_PIPE + sarbakan.visual.element.BaseElement.nNextID);
  11.       var _loc3_ = Math.random() * maze.MazeData.VIEW_TILE_WIDTH;
  12.       if(_loc3_ < maze.MazeData.MARGIN_PIPE)
  13.       {
  14.          _loc3_ = maze.MazeData.MARGIN_PIPE;
  15.       }
  16.       if(_loc3_ > maze.MazeData.VIEW_TILE_WIDTH - maze.MazeData.MARGIN_PIPE)
  17.       {
  18.          _loc3_ -= maze.MazeData.MARGIN_PIPE;
  19.       }
  20.       this.mc._x = l_oPipeInfos.x * maze.MazeData.VIEW_TILE_WIDTH + _loc3_;
  21.       this.mc._y = l_oPipeInfos.y * maze.MazeData.VIEW_TILE_HEIGHT;
  22.       this.tile(l_oPipeInfos.height * maze.MazeData.VIEW_TILE_HEIGHT);
  23.       this.mc.mcBottom._y = l_oPipeInfos.height * maze.MazeData.VIEW_TILE_HEIGHT;
  24.       this.mc.mcBottom.swapDepths(9999999);
  25.       this.bLastPipe = l_oPipeInfos.lastPipe;
  26.       this.disable();
  27.    }
  28.    function enable()
  29.    {
  30.       super.enable();
  31.       this.mc._visible = true;
  32.    }
  33.    function disable()
  34.    {
  35.       super.disable();
  36.       this.mc._visible = false;
  37.    }
  38.    function remove()
  39.    {
  40.       super.remove();
  41.    }
  42.    function tile(l_nHeight)
  43.    {
  44.       var _loc4_ = this.mc.mcMiddle1._height;
  45.       var _loc5_ = Math.round(l_nHeight / _loc4_);
  46.       var _loc3_ = undefined;
  47.       var _loc2_ = 1;
  48.       while(_loc2_ < _loc5_)
  49.       {
  50.          _loc3_ = this.mc.mcMiddle1.duplicateMovieClip("mcMiddle" + _loc2_,this.mc.getNextHighestDepth());
  51.          _loc3_._y += _loc2_ * (_loc4_ - 1);
  52.          _loc2_ = _loc2_ + 1;
  53.       }
  54.       _loc3_._height *= _loc5_ - l_nHeight / _loc4_;
  55.    }
  56.    function idle()
  57.    {
  58.       if(this.collideWithElement("spongebob",this.mc.collider))
  59.       {
  60.          this.oOwner.oDynamicElements.spongebob.oCurrentPipe = this;
  61.          this.setState("characterOn");
  62.       }
  63.    }
  64.    function characterOn()
  65.    {
  66.       if(!this.collideWithElement("spongebob",this.mc.collider))
  67.       {
  68.          if(this.oOwner.oDynamicElements.spongebob.oCurrentPipe == this)
  69.          {
  70.             this.oOwner.oDynamicElements.spongebob.oCurrentPipe = undefined;
  71.          }
  72.          this.setState("idle");
  73.       }
  74.    }
  75. }
  76.